
/*
 * sndpipe: A UNIX pipes-based audio stream processor toolkit.
 * Copyright (C) 2011  Bradley Worley
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to:
 *
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor
 *   Boston, MA  02110-1301, USA.
 */

/* ensure once-only inclusion. */
#ifndef __SNDPIPE_PIPES__
#define __SNDPIPE_PIPES__

/* define the pipes structure used to stream audio data. */
struct pipes {
  /* declare the file descriptor associated with the pipe. */
  int fd;

  /* declare the sound file handle and info structure. */
  SNDFILE *sfh;
  SF_INFO sfi;

  /* declare the buffer and its size parameter. */
  double *buf;
  unsigned long buf_size;
};

/* begin function definitions below: */

struct pipes *pipes_open_input (void);

struct pipes *pipes_open_output (SF_INFO sfi);

int pipes_close (struct pipes *p);

int pipes_write (struct pipes *p, double **buf, unsigned long frames);

int pipes_read (struct pipes *p, double ***buf, unsigned long frames);

double **pipes_buf_alloc (struct pipes *p, unsigned long *frames);

double **pipes_buf_realloc (double ***buf, struct pipes *p,
                            unsigned long frames);

void pipes_buf_free (struct pipes *p, unsigned long frames, double **buf);

int pipes_get_format (void);

unsigned long *pipes_get_channels (unsigned long *count);

#endif /* __SNDPIPE_PIPES__ */

